<%@ Page language="c#" Inherits="Dimok.Aspx.Manager.Tracking.ShipBack" CodeFile="ShipBack.aspx.cs" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<TITLE id="title" STYLE="behavior:url('#default#userData')">ShipBack</TITLE>
<META name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1"><META name="CODE_LANGUAGE" Content="C#"><META name="vs_defaultClientScript" content="JavaScript"><META name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<LINK rel="stylesheet" type="text/css" href="/CSS/Outlook.css">
<SCRIPT src="/include/common.js"></SCRIPT>
<SCRIPT src="/include/soap.js"></SCRIPT>
<SCRIPT src="/include/XML.js"></SCRIPT>
<SCRIPT src="/include/RDS.js"></SCRIPT>
<SCRIPT src="/include/Events.js"></SCRIPT>
<SCRIPT src="/Manager/Common/Common.js"></SCRIPT>
<SCRIPT src="/Manager/Common/Events.js"></SCRIPT>
<STYLE>
TABLE {font:menu;BORDER-COLLAPSE: collapse}
TD {white-space:nowrap}
</STYLE>
</HEAD>
<BODY style="MARGIN:0px" onkeypress="if(event.keyCode==24)copyBody(document)">
<TABLE datasrc="#XmlTrackers" onreadystatechange="">
	<THEAD><TR><TH>TrackerID</TH><TH>Ship</TH></TR></THEAD>
	<TR><TD><SPAN datafld="TrackerID"></SPAN></TD>
			<TD align="center"><INPUT type="checkbox" datafld="ShipIt"></TD>
	</TR>
</TABLE>
Shipment ID: <INPUT id="txtShipmentID" value="FdEx-100-"><BR>
<INPUT type="button" value="Ship Trackers Back" onclick="Trackers_ShipBack()">
<TABLE datasrc="#XmlShipments" border="1">
	<TR valign="top">
		<TD nowrap>
			<SPAN datafld="ShipmentID"></SPAN> [<SPAN datafld="DateStamp"></SPAN>]<BR>
			<INPUT type="button" value="Arrived" onclick="Trackers_InHouse(this,true)">
		</TD>
		<TD><TABLE datasrc="#XmlShipments" dataFld="Trackers" border="0" style="FONT-FAMILY: Monospace">
					<TR>
						<TD><SPAN datafld="TrackerID" onclick="showTracker(this.innerText)"></SPAN></TD>
						<TD><SPAN dataformatas="html" datafld="CheckBox"></SPAN></TD>
					</TR>
				</TABLE>
		</TD>
	</TR>
</TABLE>
<XML id="XmlTrackers" runat="server"></XML>
<XML id="XmlShipments" runat="server"></XML>
</BODY>
</HTML>
<SCRIPT language="javascript">
if( !this.frameElement )window.attachEvent("onresize",doResize);
var udID = location.pathname.replace(/(\.|\/)/g,"_");
title.load(udID);
if( !this.frameElement )
	setTimeout(function(){try{external.dialogWidth =title.getAttribute("WIN_W")+"px";external.dialogHeight=title.getAttribute("WIN_H")+"px";}catch(e){}},100);
//alert(XmlShipments.xml);
function doResize(ev,thread){
	if( !thread ){
		clearTimeout(doResize.proc);
		return setTimeout(function(){doResize(ev,true)},500);
	}
	title.setAttribute("WIN_W",document.body.offsetWidth+8);
	title.setAttribute("WIN_H",document.body.offsetHeight+31);
	title.save(udID);
}
var rs = XmlTrackers.recordset;
initWS("Common","../Common/Common.asmx");
function Trackers_InHouse(el,all){
	var trackerIDs = all ? _getTrackers(el) : rsField(el,"TrackerID");
	if( !confirm(trackerIDs+" are back in the building?") )return;
	var ret = WS(CO(),trackerIDs);
	if( showSOAPError(ret) )return false;
	fireListRefresh({menuPath:"Tracking ->"});
	// Local
	function _getTrackers(el){
		var rs = rsField(el,"Trackers").Value;
		for( var a=[]; !rs.EOF; rs.MoveNext() )
			if( document.all["chk"+rs("TrackerID").Value] && document.all["chk"+rs("TrackerID").Value].checked )
				a.push(rs("TrackerID").Value);
		return a.join(",");
	}
}
function Trackers_ShipBack(){
	var shipmentID = txtShipmentID.value;
	if( !shipmentID )return alert("Shipment ID must be provided.")
	var a = new Array();
	for( rs.MoveFirst(); !rs.EOF; rs.MoveNext() )
		if( eval(rs("ShipIt").value) )a.push(rs("TrackerID").value);
	var ret = WS(CO(),a,shipmentID);
	if( showSOAPError(ret) )return false;
	fireListRefresh({menuPath:"Tracking -> Trackers"});
	alert("Done!");
	top.close();
}
</SCRIPT>
